<script language="javascript" type="text/javascript" src="p_usuario/valida_editar.js"></script>
<?php 
$id = $_GET['i'];
$resul = mysql_query("SELECT usuarios.id, usuarios.username, grupos.name, membros.membro, membro_id, group_id, usuarios.status FROM usuarios, grupos, membros WHERE usuarios.group_id = grupos.id AND usuarios.membro_id = membros.id AND usuarios.id = $id");
$user = mysql_fetch_array($resul);
?>
<div class="form">
	<div class="row">
		<div class="col-md-12">
			<div class="page-header">
				<h2>Editar Usu&aacuterio</h2>
			</div>
		</div>
	</div>
	<div class="row">
	<div class="col-md-3">
			<?php include "actions-usuario.php"; ?>			
		</div><!-- end col md 3 -->
		<div class="col-md-9">
		<!-- HEAD DE FORMULÃ�RIO -->
		<div class="panel panel-default">
			<div class="panel-heading"><h5>Formul&aacuterio para editar registro</h5></div>
			<div class="panel-body">
			<!-- FORMULÃ�RIO -->
			<form  method="post" name="form1" action="p_usuario/editar.php">
			
				<div class="row">
					<div class="form-group col-md-6">
						<label for="nome">Membro ou Funcion&aacuterio</label>
   	   					<input type="text" class="form-control " name="txtnome" id="txtnome" value="<?php echo $user['membro'];?>" disabled> 
						<input type="hidden" name="id" value="<?php echo $id;?>">
					</div>
					<div class="form-group col-md-6">
						<label for="status">Situa&ccedil&atildeo</label>
    					<select name="status" class="form-control">
		          			<option value='selecione'>Selecione...</option>
		          			<?php if($user['status'] == 1){ ?>
								<option value="<?php echo $user['status']; ?>" selected>Usu&aacuterio Ativo</option>
								<option value="0">Usu&aacuterio Inativo</option>
							<?php } else{?>
								<option value="<?php echo $user['status']; ?>" selected>Usu&aacuterio Inativo</option>
								<option value="1">Usu&aacuterio Ativo</option>
							<?php }?>
		          		</select>
		          	</div>
				</div>
				<div class="row">	
					<div class="form-group col-md-6">
						<label for="username">Login (M&aacuteximo 15 caracteres)</label>
    					<input type="text" class="form-control" id="login" name="login" value="<?php echo $user['username'];?>" maxlength="15">
					</div>
					<div class="form-group col-md-6">
						<label for="grupo">Grupo ou Tipo de Usu&aacuterio</label>
    					<select name="grupo" class="form-control">
		          			<option value='selecione'>Selecione...</option>
		          			<?php
									//require "banco/ConexaoBanco.php";
									$query = mysql_query("SELECT id, name FROM grupos");
									while($lista = mysql_fetch_array($query)) { ?> 
									<?php if($lista['id'] == $user['group_id']){ ?>
										<option value="<?php echo $lista['id']; ?>" selected><?php echo $lista['name']; ?></option>
									<?php } else{?>
										<option value="<?php echo $lista['id']; ?>"><?php echo $lista['name']; ?></option>
									<?php }?>
								<?php } mysql_close();?>
		          		</select>
					</div>
				</div>
				<div class="row">
					<div class="col-md-12">
						<div class="alert alert-warning alert-dismissable">
							Preencha os dados abaixo apenas se desejar trocar a senha do usu&aacuterio.
						</div>
					</div>
				</div>
				<div class="row">
					<div class="form-group col-md-6">
						<label for="senha">Senha</label>
    					<input type="password" class="form-control" id="senha" placeholder="******" name="senha" value="<?php //echo $user['password'];?>" maxlength="6">
					</div>
					<div class="form-group col-md-6">
						<label for="confirma">Confirme a senha</label>
    					<input type="password" class="form-control" id="conf_senha" name="conf_senha" placeholder="******" maxlength="6">
					</div>
					
				
				</div>
				<div class="row">
					<div class="form-group col-md-2">
						<input type="submit" value="Salvar" class="btn btn-default " name="enviar" onclick="return valida()" >
					</div>
				</div>
			</form>
			</div>
		</div>

		</div><!-- end col md 12 -->
	</div><!-- end row -->
</div>
			